<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>京东 - 多快好省，只为品质生活</title>
    <link href="https://cdn.jsdelivr.net/npm/font-awesome@4.7.0/css/font-awesome.min.css" rel="stylesheet">
    <style>
        /* 全局样式 */
        * {
            margin: 0;
            padding: 0;
            box-sizing: border-box;
        }
        
        body {
            font-family: 'Microsoft YaHei', sans-serif;
            background-color: #f5f5f5;
            min-height: 100vh;
            display: flex;
            flex-direction: column;
        }
        
        /* 顶部导航 */
        .top-nav {
            background-color: #e3e4e5;
            height: 30px;
            line-height: 30px;
            font-size: 12px;
            color: #999;
        }
        
        .top-nav-container {
            max-width: 1200px;
            margin: 0 auto;
            display: flex;
            justify-content: space-between;
        }
        
        .top-nav-left, .top-nav-right {
            display: flex;
            list-style: none;
        }
        
        .top-nav-item {
            margin: 0 10px;
        }
        
        .top-nav-item a {
            color: #999;
            text-decoration: none;
        }
        
        .top-nav-item a:hover {
            color: #e4393c;
        }
        
        /* 头部 */
        .header {
            background-color: #fff;
            padding: 20px 0;
        }
        
        .header-container {
            max-width: 1200px;
            margin: 0 auto;
            display: flex;
            align-items: center;
            justify-content: space-between;
        }
        
        .logo img {
            height: 60px;
        }
        
        .search-box {
            display: flex;
            width: 500px;
            height: 40px;
            border: 2px solid #e4393c;
            border-radius: 20px;
            overflow: hidden;
        }
        
        .search-input {
            flex: 1;
            border: none;
            padding: 0 15px;
            font-size: 14px;
        }
        
        .search-input:focus {
            outline: none;
        }
        
        .search-button {
            width: 80px;
            background-color: #e4393c;
            color: #fff;
            border: none;
            cursor: pointer;
            font-size: 16px;
        }
        
        .cart {
            position: relative;
            width: 130px;
            height: 40px;
            background-color: #f9f9f9;
            border: 1px solid #ddd;
            border-radius: 20px;
            display: flex;
            align-items: center;
            justify-content: center;
            cursor: pointer;
        }
        
        .cart-icon {
            margin-right: 5px;
            color: #e4393c;
        }
        
        .cart-count {
            position: absolute;
            top: -8px;
            right: 20px;
            background-color: #e4393c;
            color: #fff;
            font-size: 12px;
            width: 18px;
            height: 18px;
            line-height: 18px;
            text-align: center;
            border-radius: 50%;
        }
        
        /* 主导航 */
        .main-nav {
            background-color: #fff;
            border-bottom: 2px solid #e4393c;
        }
        
        .main-nav-container {
            max-width: 1200px;
            margin: 0 auto;
            display: flex;
            height: 40px;
            line-height: 40px;
        }
        
        .main-nav-item {
            margin-right: 20px;
            padding: 0 10px;
            font-size: 16px;
            font-weight: 500;
            cursor: pointer;
        }
        
        .main-nav-item:hover {
            color: #e4393c;
        }
        
        /* 轮播图 */
        .banner {
            height: 400px;
            background-color: #f5f5f5;
            position: relative;
            overflow: hidden;
        }
        
        .banner-slide {
            height: 100%;
            display: flex;
            transition: transform 0.5s ease-in-out;
        }
        
        .banner-item {
            min-width: 100%;
            height: 100%;
            background-position: center;
            background-size: cover;
        }
        
        .banner-dots {
            position: absolute;
            bottom: 20px;
            left: 50%;
            transform: translateX(-50%);
            display: flex;
        }
        
        .banner-dot {
            width: 12px;
            height: 12px;
            border-radius: 50%;
            background-color: rgba(255, 255, 255, 0.5);
            margin: 0 5px;
            cursor: pointer;
        }
        
        .banner-dot.active {
            background-color: #fff;
        }
        
        .banner-prev, .banner-next {
            position: absolute;
            top: 50%;
            transform: translateY(-50%);
            width: 40px;
            height: 80px;
            background-color: rgba(0, 0, 0, 0.3);
            color: #fff;
            display: flex;
            align-items: center;
            justify-content: center;
            font-size: 24px;
            cursor: pointer;
            opacity: 0;
            transition: opacity 0.3s;
        }
        
        .banner:hover .banner-prev, .banner:hover .banner-next {
            opacity: 1;
        }
        
        .banner-prev {
            left: 20px;
        }
        
        .banner-next {
            right: 20px;
        }
        
        /* 商品区域 */
        .products-container {
            max-width: 1200px;
            margin: 30px auto;
        }
        
        .section-title {
            font-size: 24px;
            font-weight: 500;
            margin-bottom: 20px;
        }
        
        .products-grid {
            display: grid;
            grid-template-columns: repeat(5, 1fr);
            gap: 20px;
        }
        
        .product-card {
            background-color: #fff;
            border-radius: 8px;
            overflow: hidden;
            box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
            transition: transform 0.3s;
        }
        
        .product-card:hover {
            transform: translateY(-5px);
        }
        
        .product-image {
            height: 200px;
            overflow: hidden;
        }
        
        .product-image img {
            width: 100%;
            height: 100%;
            object-fit: cover;
        }
        
        .product-info {
            padding: 15px;
        }
        
        .product-name {
            font-size: 14px;
            margin-bottom: 10px;
            height: 40px;
            overflow: hidden;
            text-overflow: ellipsis;
            display: -webkit-box;
            -webkit-line-clamp: 2;
            -webkit-box-orient: vertical;
        }
        
        .product-price {
            font-size: 18px;
            font-weight: 500;
            color: #e4393c;
            margin-bottom: 10px;
        }
        
        .product-rating {
            font-size: 12px;
            color: #999;
        }
        
        .product-rating .fa-star {
            color: #ffc107;
        }
        
        /* 底部 */
        .footer {
            background-color: #fff;
            padding: 20px 0;
            border-top: 1px solid #ddd;
        }
        
        .footer-container {
            max-width: 1200px;
            margin: 0 auto;
            text-align: center;
            color: #666;
            font-size: 12px;
        }
        
        .footer-links {
            margin-bottom: 10px;
        }
        
        .footer-links a {
            color: #666;
            text-decoration: none;
            margin: 0 10px;
        }
        
        .footer-links a:hover {
            color: #e4393c;
        }
        
        /* 用户下拉菜单 */
        .user-menu {
            position: relative;
        }
        
        .user-menu-toggle {
            cursor: pointer;
            display: flex;
            align-items: center;
        }
        
        .user-avatar {
            width: 24px;
            height: 24px;
            border-radius: 50%;
            background-color: #e4393c;
            color: #fff;
            display: flex;
            align-items: center;
            justify-content: center;
            margin-right: 5px;
        }
        
        .user-dropdown {
            display: none;
            position: absolute;
            top: 30px;
            right: 0;
            background-color: #fff;
            border: 1px solid #ddd;
            border-radius: 4px;
            width: 120px;
            z-index: 100;
            box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
        }
        
        .user-dropdown-item {
            padding: 8px 15px;
            font-size: 14px;
            cursor: pointer;
        }
        
        .user-dropdown-item:hover {
            background-color: #f5f5f5;
        }
        
        .user-menu:hover .user-dropdown {
            display: block;
        }
        
        /* 响应式 */
        @media (max-width: 1200px) {
            .header-container, .main-nav-container, .products-container {
                padding: 0 20px;
            }
            
            .search-box {
                width: 400px;
            }
            
            .products-grid {
                grid-template-columns: repeat(4, 1fr);
            }
        }
        
        @media (max-width: 992px) {
            .search-box {
                width: 300px;
            }
            
            .products-grid {
                grid-template-columns: repeat(3, 1fr);
            }
            
            .banner {
                height: 300px;
            }
        }
        
        @media (max-width: 768px) {
            .header-container {
                flex-direction: column;
                align-items: flex-start;
            }
            
            .search-box {
                width: 100%;
                margin: 15px 0;
            }
            
            .cart {
                align-self: flex-end;
                margin-top: -55px;
            }
            
            .main-nav {
                display: none;
            }
            
            .products-grid {
                grid-template-columns: repeat(2, 1fr);
            }
            
            .banner {
                height: 200px;
            }
            
            .top-nav {
                display: none;
            }
        }
    </style>
</head>
<body>
    <!-- 顶部导航 -->
    <div class="top-nav">
        <div class="top-nav-container">
            <ul class="top-nav-left">
                <li class="top-nav-item"><a href="#">北京</a></li>
            </ul>
            <ul class="top-nav-right">
                <!-- 未登录状态 -->
                <li id="login-link" class="top-nav-item"><a href="login.html">你好，请登录</a></li>
                <li id="register-link" class="top-nav-item"><a href="register.html">免费注册</a></li>
                
                <!-- 登录状态 -->
                <li id="user-menu" class="top-nav-item user-menu" style="display: none;">
                    <div class="user-menu-toggle">
                        <div class="user-avatar">
                            <span id="user-initial">U</span>
                        </div>
                        <span id="username-display">用户名</span>
                    </div>
                    <div class="user-dropdown">
                        <div class="user-dropdown-item" onclick="goToProfile()">个人中心</div>
                        <div class="user-dropdown-item" onclick="logout()">退出登录</div>
                    </div>
                </li>
                
                <li class="top-nav-item"><a href="#">我的订单</a></li>
                <li class="top-nav-item"><a href="#">我的京东</a></li>
                <li class="top-nav-item"><a href="#">客户服务</a></li>
            </ul>
        </div>
    </div>
    
    <!-- 头部 -->
    <header class="header">
        <div class="header-container">
            <div class="logo">
                <a href="index.html"><img src="https://picsum.photos/id/237/200/60" alt="京东Logo"></a>
            </div>
            
            <div class="search-box">
                <input type="text" class="search-input" placeholder="搜索商品">
                <button class="search-button"><i class="fa fa-search"></i></button>
            </div>
            
            <div class="cart">
                <i class="fa fa-shopping-cart cart-icon"></i>
                <span>购物车</span>
                <span class="cart-count">0</span>
            </div>
        </div>
    </header>
    
    <!-- 主导航 -->
    <nav class="main-nav">
        <div class="main-nav-container">
            <div class="main-nav-item">全部分类</div>
            <div class="main-nav-item">手机</div>
            <div class="main-nav-item">家电</div>
            <div class="main-nav-item">电脑</div>
            <div class="main-nav-item">数码</div>
            <div class="main-nav-item">图书</div>
            <div class="main-nav-item">家居</div>
            <div class="main-nav-item">生鲜</div>
            <div class="main-nav-item">食品</div>
            <div class="main-nav-item">服饰</div>
        </div>
    </nav>
    
    <!-- 轮播图 -->
    <div class="banner">
        <div class="banner-slide">
            <div class="banner-item" style="background-image: url('https://picsum.photos/id/26/1920/400');"></div>
            <div class="banner-item" style="background-image: url('https://picsum.photos/id/96/1920/400');"></div>
            <div class="banner-item" style="background-image: url('https://picsum.photos/id/106/1920/400');"></div>
        </div>
        <div class="banner-dots">
            <div class="banner-dot active"></div>
            <div class="banner-dot"></div>
            <div class="banner-dot"></div>
        </div>
        <div class="banner-prev"><i class="fa fa-angle-left"></i></div>
        <div class="banner-next"><i class="fa fa-angle-right"></i></div>
    </div>
    
    <!-- 商品区域 -->
    <main class="products-container">
        <div class="section-title">热门推荐</div>
        <div class="products-grid">
            <div class="product-card">
                <div class="product-image">
                    <img src="https://img1.360buyimg.com/n6/jfs/t1/266815/21/323/161406/6763f006F4479d89d/1caa7f9cc583578f.png" alt="智能手表">
                </div>
                <div class="product-info">
                    <div class="product-name">高品质智能手表，支持心率监测</div>
                    <div class="product-price">¥1,299.00</div>
                    <div class="product-rating">
                        <i class="fa fa-star"></i>
                        <i class="fa fa-star"></i>
                        <i class="fa fa-star"></i>
                        <i class="fa fa-star"></i>
                        <i class="fa fa-star-half-o"></i>
                        <span>(128)</span>
                    </div>
                </div>
            </div>
            
            <div class="product-card">
                <div class="product-image">
                    <img src="https://img1.360buyimg.com/n6/jfs/t1/287354/38/1611/68007/6811ebefFddd4dd2f/c77f17bb79715f70.jpg" alt="笔记本电脑">
                </div>
                <div class="product-info">
                    <div class="product-name">超薄笔记本电脑，高性能处理器</div>
                    <div class="product-price">¥4,599.00</div>
                    <div class="product-rating">
                        <i class="fa fa-star"></i>
                        <i class="fa fa-star"></i>
                        <i class="fa fa-star"></i>
                        <i class="fa fa-star"></i>
                        <i class="fa fa-star-o"></i>
                        <span>(86)</span>
                    </div>
                </div>
            </div>
            
            <div class="product-card">
                <div class="product-image">
                    <img src="https://img1.360buyimg.com/n6/jfs/t1/241451/3/5827/103392/65f12732F86796709/61224dc2a0ff9f9b.jpg" alt="智能电视">
                </div>
                <div class="product-info">
                    <div class="product-name">高清智能电视，4K超高清画质</div>
                    <div class="product-price">¥3,299.00</div>
                    <div class="product-rating">
                        <i class="fa fa-star"></i>
                        <i class="fa fa-star"></i>
                        <i class="fa fa-star"></i>
                        <i class="fa fa-star"></i>
                        <i class="fa fa-star"></i>
                        <span>(215)</span>
                    </div>
                </div>
            </div>
            
            <div class="product-card">
                <div class="product-image">
                    <img src="https://img1.360buyimg.com/n6/jfs/t1/283283/37/4060/464099/67d7e12fF96672857/83ee5c8c34a4a8aa.png" alt="相机">
                </div>
                <div class="product-info">
                    <div class="product-name">专业摄影相机，高清画质</div>
                    <div class="product-price">¥5,699.00</div>
                    <div class="product-rating">
                        <i class="fa fa-star"></i>
                        <i class="fa fa-star"></i>
                        <i class="fa fa-star"></i>
                        <i class="fa fa-star-half-o"></i>
                        <i class="fa fa-star-o"></i>
                        <span>(47)</span>
                    </div>
                </div>
            </div>
            
            <div class="product-card">
                <div class="product-image">
                    <img src="https://img1.360buyimg.com/n6/jfs/t1/98332/20/53384/49886/6725c0d5Fd599cc7d/8e5c4e5c73bede80.jpg" alt="投影仪">
                </div>
                <div class="product-info">
                    <div class="product-name">便携式投影仪，家庭影院</div>
                    <div class="product-price">¥2,399.00</div>
                    <div class="product-rating">
                        <i class="fa fa-star"></i>
                        <i class="fa fa-star"></i>
                        <i class="fa fa-star"></i>
                        <i class="fa fa-star"></i>
                        <i class="fa fa-star-o"></i>
                        <span>(92)</span>
                    </div>
                </div>
            </div>
        </div>
        
        <div class="section-title">新品上市</div>
        <div class="products-grid">
            <div class="product-card">
                <div class="product-image">
                    <img src="https://img1.360buyimg.com/n6/jfs/t1/226775/30/32867/100326/67bae0faF96b8e4d0/fc8b0671b90ec760.jpg" alt="智能手环">
                </div>
                <div class="product-info">
                    <div class="product-name">智能手环，健康监测</div>
                    <div class="product-price">¥299.00</div>
                    <div class="product-rating">
                        <i class="fa fa-star"></i>
                        <i class="fa fa-star"></i>
                        <i class="fa fa-star"></i>
                        <i class="fa fa-star"></i>
                        <i class="fa fa-star-o"></i>
                        <span>(65)</span>
                    </div>
                </div>
            </div>
            
            <div class="product-card">
                <div class="product-image">
                    <img src="https://img1.360buyimg.com/n6/jfs/t1/259217/24/5573/171470/677263a0F96a7338c/d336f7b88242ac54.jpg" alt="无线耳机">
                </div>
                <div class="product-info">
                    <div class="product-name">无线蓝牙耳机，降噪功能</div>
                    <div class="product-price">¥599.00</div>
                    <div class="product-rating">
                        <i class="fa fa-star"></i>
                        <i class="fa fa-star"></i>
                        <i class="fa fa-star"></i>
                        <i class="fa fa-star"></i>
                        <i class="fa fa-star-half-o"></i>
                        <span>(112)</span>
                    </div>
                </div>
            </div>
            
            <div class="product-card">
                <div class="product-image">
                    <img src="https://img1.360buyimg.com/n6/jfs/t1/259345/27/13216/58007/678a24a7F3cd89e25/ac0f6a49e7e7c274.png" alt="平板电脑">
                </div>
                <div class="product-info">
                    <div class="product-name">轻薄平板电脑，高性能</div>
                    <div class="product-price">¥2,799.00</div>
                    <div class="product-rating">
                        <i class="fa fa-star"></i>
                        <i class="fa fa-star"></i>
                        <i class="fa fa-star"></i>
                        <i class="fa fa-star"></i>
                        <i class="fa fa-star-o"></i>
                        <span>(78)</span>
                    </div>
                </div>
            </div>
            
            <div class="product-card">
                <div class="product-image">
                    <img src="https://img1.360buyimg.com/n6/jfs/t1/312453/14/7141/52736/68414f37F14bc48a7/577aa450b0b5e9f3.jpg" alt="游戏手柄">
                </div>
                <div class="product-info">
                    <div class="product-name">游戏手柄，无线连接</div>
                    <div class="product-price">¥399.00</div>
                    <div class="product-rating">
                        <i class="fa fa-star"></i>
                        <i class="fa fa-star"></i>
                        <i class="fa fa-star"></i>
                        <i class="fa fa-star"></i>
                        <i class="fa fa-star-o"></i>
                        <span>(43)</span>
                    </div>
                </div>
            </div>
            
            <div class="product-card">
                <div class="product-image">
                    <img src="https://img1.360buyimg.com/n6/jfs/t1/267850/18/3515/291109/676d405dF9806a1e8/b9514a62379bacde.jpg" alt="智能家居">
                </div>
                <div class="product-info">
                    <div class="product-name">智能家居套装，智能控制</div>
                    <div class="product-price">¥1,299.00</div>
                    <div class="product-rating">
                        <i class="fa fa-star"></i>
                        <i class="fa fa-star"></i>
                        <i class="fa fa-star"></i>
                        <i class="fa fa-star"></i>
                        <i class="fa fa-star-half-o"></i>
                        <span>(59)</span>
                    </div>
                </div>
            </div>
        </div>
    </main>
    
    <!-- 底部 -->
    <footer class="footer">
        <div class="footer-container">
            <div class="footer-links">
                <a href="#" style="color: #666; text-decoration: none; margin: 0 10px;">关于我们</a>
                <a href="#" style="color: #666; text-decoration: none; margin: 0 10px;">联系我们</a>
                <a href="#" style="color: #666; text-decoration: none; margin: 0 10px;">网站地图</a>
                <a href="#" style="color: #666; text-decoration: none; margin: 0 10px;">隐私政策</a>
                <a href="#" style="color: #666; text-decoration: none; margin: 0 10px;">京东社区</a>
                <a href="#" style="color: #666; text-decoration: none; margin: 0 10px;">诚聘英才</a>
            </div>
            <p style="margin-top: 10px;">Copyright © 2004-2023 京东JD.com 版权所有 | 京ICP证070359号</p>
        </div>
    </footer>
    
    <script>
        // 轮播图功能
        const bannerSlide = document.querySelector('.banner-slide');
        const bannerItems = document.querySelectorAll('.banner-item');
        const bannerDots = document.querySelectorAll('.banner-dot');
        const bannerPrev = document.querySelector('.banner-prev');
        const bannerNext = document.querySelector('.banner-next');
        
        let currentIndex = 0;
        const slideWidth = 100; // 100%
        
        // 初始化轮播图
        function initBanner() {
            updateBanner();
            
            // 设置自动轮播
            setInterval(nextSlide, 5000);
            
            // 绑定按钮事件
            bannerPrev.addEventListener('click', prevSlide);
            bannerNext.addEventListener('click', nextSlide);
            
            // 绑定指示点事件
            bannerDots.forEach((dot, index) => {
                dot.addEventListener('click', () => {
                    currentIndex = index;
                    updateBanner();
                });
            });
        }
        
        // 更新轮播图位置和指示点
        function updateBanner() {
            // 更新轮播图位置
            bannerSlide.style.transform = `translateX(-${currentIndex * slideWidth}%)`;
            
            // 更新指示点状态
            bannerDots.forEach((dot, index) => {
                if (index === currentIndex) {
                    dot.classList.add('active');
                } else {
                    dot.classList.remove('active');
                }
            });
        }
        
        // 下一张幻灯片
        function nextSlide() {
            currentIndex = (currentIndex + 1) % bannerItems.length;
            updateBanner();
        }
        
        // 上一张幻灯片
        function prevSlide() {
            currentIndex = (currentIndex - 1 + bannerItems.length) % bannerItems.length;
            updateBanner();
        }
        
        // 检查登录状态
        function checkLoginStatus() {
            // 从sessionStorage获取登录状态
            const username = sessionStorage.getItem('username');
            
            if (username) {
                // 用户已登录
                document.getElementById('login-link').style.display = 'none';
                document.getElementById('register-link').style.display = 'none';
                document.getElementById('user-menu').style.display = 'block';
                document.getElementById('username-display').textContent = username;
                
                // 设置用户头像首字母
                document.getElementById('user-initial').textContent = username.charAt(0).toUpperCase();
            } else {
                // 用户未登录
                document.getElementById('login-link').style.display = 'block';
                document.getElementById('register-link').style.display = 'block';
                document.getElementById('user-menu').style.display = 'none';
            }
        }
        
        // 跳转到个人中心
        function goToProfile() {
            window.location.href = 'profile.html';
        }
        
        // 退出登录
        function logout() {
            // 清除sessionStorage中的登录状态
            sessionStorage.removeItem('username');
            
            // 刷新页面
            window.location.href = 'index.html';
        }
        
        // 页面加载时初始化
        window.addEventListener('load', function() {
            initBanner();
            checkLoginStatus();
        });
    </script>
</body>
</html>
